package com.shiku.imserver.common.utils;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil {
    public static Properties loadPropertyFile(String propertyFile) {
        InputStream inputStream;
        if (StringUtils.isEmpty(propertyFile)) {
            return null;
        }
        Properties prop = new Properties();
        InputStream inputStream2 = null;
        try {
            if (propertyFile.startsWith("classpath:")) {
                System.out.println("loadPropertyFile ===> " + propertyFile);
                inputStream = PropertiesUtil.class.getClassLoader().getResourceAsStream(propertyFile.replace("classpath:", ""));
            } else {
                inputStream = new FileInputStream(propertyFile);
            }
            prop.load(inputStream);
            if (inputStream == null) {
                return prop;
            }
            try {
                inputStream.close();
                return prop;
            } catch (IOException e) {
                e.printStackTrace();
                return prop;
            }
        } catch (Exception e2) {
            e2.printStackTrace();
            if (inputStream2 != null) {
                try {
                    inputStream2.close();
                } catch (IOException e3) {
                    e3.printStackTrace();
                }
            }
            return null;
        } catch (Throwable th) {
            if (inputStream2 != null) {
                try {
                    inputStream2.close();
                } catch (IOException e4) {
                    e4.printStackTrace();
                }
            }
            throw th;
        }
    }
}
